.PHONY: default all release-server release-all distclean
export GOPATH := $(shell pwd)

ifeq ($(GOARCH),)
export GOARCH := 386
endif

CROSS_COMPILER ?= arm-linux-

BUILDTAGS = debug
BUILDFLAGS = -s -w

default: all

sample:
	@env | grep 'GO'
	go fmt sample/...
	go get -tags '$(BUILDTAGS)' -d -v sample/...
	CC=$(if $(findstring arm,$(GOARCH)),"arm-linux-gcc","") go install -tags '$(BUILDTAGS)' -ldflags '$(BUILDFLAGS)' sample

all: sample

release-server: BUILDTAGS = release
release-server: server

release-all: release-server

distclean:
	@go clean -i -r sample/... > /dev/null 2>&1
	@rm -rf bin pkg
